package com.gjy.aop;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-01-30 15:55:24
 */
@Slf4j
@Component
@Aspect
public class DataPermissionAspect {

    @Before("@annotation(needDataPermission) && args(dataPermission,..)")
    public void obtainDataPermission(NeedDataPermission needDataPermission, DataPermission dataPermission) {
        if (ObjectUtil.isNull(dataPermission) || ObjectUtil.isNull(dataPermission.getUserId())) {
            log.error("未初始化权限对象或未设置用户编号：{}", dataPermission);
            return;
        }
        // 设置数据权限
    }
}
